﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Tool.Framework;
@{
    Periodical journal = ViewBag.Journal;
    ViewBag.Title = "手工添加稿件 -- " + journal.Name;
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
<link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        手工维护稿件</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/Member/Index" class="tip-bottom"><i class="icon-home"></i>起始页</a>
    <a href="javascript:">投稿</a> <a class="current">手工维护稿件</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-pencil"></i></span>
                    <h5>
                        稿件信息</h5>
                    <h5 style="float: right; color: Red;">
                        *为必填</h5>
                </div>
                @{
                    List<Author> author = ViewBag.Author;
                }
                <div class="widget-content nopadding">
                    <form class="form-horizontal" method="post" enctype="multipart/form-data" 
                        action="/WorkSpace/console/manualArticle">
                    <input type="hidden" name="journalId" value="@journal.Id" />
                    <input type="hidden" id="hidAuthor" name="Author" />
                    <input type="hidden" name="GJFW" />
                    <div class="step">
                        <div class="control-group">
                            <label class="control-label">
                                期刊名称</label>
                            <div class="controls">
                                <input id="name" readonly="readonly" type="text" name="Name" value="@journal.Name" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                标题 (*)</label>
                            <div class="controls">
                                <input type="text" name="Title" class="{required:true}" placeholder="中文标题" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                Title (*)</label>
                            <div class="controls">
                                <input type="text" name="Title_EN" class="{required:true}" placeholder="英文标题" />
                            </div>
                        </div>
                        <div id="authorbox" class="control-group">
                            <label class="control-label">
                                作者 (*)</label>
                            <div class="controls">
                                <select id="sltAuthor" multiple>
                                    @{
                                        if (author != null && author.Any())
                                        {
                                            for (int i = 0, len = author.Count; i < len; i++)
                                            {
                                                if (i == 0)
                                                {
                                        <option selected="selected" value="@author[i].Id">@author[i].LastName @author[i].FirstName</option>
                                                }
                                                else
                                                { 
                                        <option value="@author[i].Id">@author[i].LastName @author[i].FirstName</option>
                                                }
                                            }
                                        }
                                    }
                                </select>
                                <div class="help-inline padding-top">
                                    <a style="color: #000;">请按顺序添加</a> <a href="/workspace/console/authorinfo">添加作者</a></div>
                            </div>
                        </div>
                        <div class="control-group" id="gjfwbox">
                            <label class="control-label">
                                稿件范围：
                            </label>
                            <div class="controls">
                                @{
                                    string[] fw = journal.ZGFW == null ? null : journal.ZGFW.Split(';');
                                    if (fw != null && fw.Any())
                                    {
                                        int i = 0;
                                        foreach (var item in fw)
                                        {
                                            if (String.IsNullOrEmpty(item))
                                            {
                                                continue;
                                            }
                                            string ctlid = "ckbGJFW" + i;
                                    <div style="width: 80%;">
                                        <div style="float: left; width: 200px;">
                                            <label class="checkbox">
                                                <input type="checkbox" id="@ctlid" value="@item" />
                                                @item
                                            </label>
                                        </div>
                                    </div>
                                        
                                            i++;
                                        }
                                    }
                                }
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要 (*)</label>
                            <div class="controls">
                                <textarea name="Abstract" rows="10" cols="15" class="{required:true}" placeholder="中文摘要"></textarea>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字 (*)</label>
                            <div class="controls">
                                <input type="text" name="KeyWords" class="{required:true}" placeholder="中文关键字" />
                               <span class="help-block">关键字之间请用英文逗号“,”隔开</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                Abstract (*)</label>
                            <div class="controls">
                                <textarea name="Abstract_EN" rows="10" cols="15" class="{required:true}" placeholder="英文摘要"></textarea>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                Keywords (*)</label>
                            <div class="controls">
                                <input type="text" name="KeyWords_EN" class="{required:true}" placeholder="英文关键词" />
                                <span class="help-block">关键字之间请用英文逗号“,”隔开</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                上传稿件 (*)</label>
                            <div class="controls">
                                <input type="file" name="Appendix" class="{required:true, accept:'doc|docx|pdf|zip|7z|rar'}"}" />
                                <span class="help-block">支持文件类型：Doc Docx PDF Zip GZip 7-Zip RAR</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <a class="btn btn-primary" href="/workspace/console/index">返回</a>
                        <input id="next" class="btn btn-primary" type="submit" value="Submit" />
                    </div>
                    <div id="submitted">
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@section tail
{
    <script type="text/javascript" src="/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/scripts/unicorn.wizard.js"></script>
    <script type="text/javascript" src="/scripts/jquery.metadata.js"></script>
    <script type="text/javascript" src="/scripts/jquery.wizard.js"></script>
    <script type="text/javascript" src="/scripts/select2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likpublish').addClass('open active');
            $('#sltAuthor').select2();
            $('form').validate({
                errorClass: "help-inline",
                errorElement: "span",
                highlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').addClass('error');
                },
                unhighlight: function (element, errorClass, validClass) {
                    $(element).parents('.control-group').removeClass('error');
                },
                submitHandler: function (form) {
                    var choose = $('.chooseitem').length;
                    if (choose == 0) {
                        $('#authorbox').addClass('error');
                        $('#authorbox').children('.controls:eq(0)').append(
                            $('<span generated="true" class="help-inline" style="">required.</span>')
                        );
                        return false;
                    }
                    else {
                        $('#authorbox').removeClass('error');
                        $('#authorbox').children('.controls:eq(0)').children('.help-inline:eq(0)').remove();
                    }
                    var sid = "";
                    $('.chooseitem').each(function () {
                        var ci = $(this).children('div').text();
                        $('#sltAuthor').children('option').each(function () {
                            if (ci == $(this).text()) {
                                sid += $(this).val() + ';';
                            }
                        });
                    });
                    $('#hidAuthor').val(sid);
                    var gjfw = '';
                    $(':checkbox:checked').each(function () {
                        gjfw += $(this).val() + ';';
                    });
                    if (gjfw == '') {
                        $(':checkbox:eq(0)').focus();
                        $('#gjfwbox').addClass('error');
                        return false;
                    }
                    $('input[name="GJFW"]').val(gjfw);
                    return true;
                }
            });
        });
    </script>
}
